﻿using HuiZe.education.View;
using HuiZe.education.ViewModel;
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Animation;

namespace HuiZe.education
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainView : Window
    {
        private static MainView _main_window = null;
        public static Window Instance
        {
            get
            {
                return _main_window;
            }
        }

        public MainView()
        {
            InitializeComponent();
     
            Loaded += MainView_Loaded;
            IsVisibleChanged += MainView_IsVisibleChanged;
            _main_window = this;

            this.MaxWidth = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
            this.MaxHeight = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;

        }

        private void MainView_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if ((bool)e.NewValue)
            {
                this.BeginAnimation(OpacityProperty,(DoubleAnimation)FindResource("doubleAnimation"));
            }
        }

        private void MainView_Loaded(object sender, RoutedEventArgs e)
        {
            MainViewModel mainViewModel = DataContext as MainViewModel;
            mainViewModel.MainView = this;
     
        }

        private void personCenter_Click(object sender, RoutedEventArgs e)
        {
            personPopup.IsOpen = true;
        }

        private void YCButton_Click(object sender, RoutedEventArgs e)
        {
            personPopup.IsOpen = false;
        }

        private void personCenter_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            personPopup.IsOpen = true;
        }

        private void YCButton_Click_2(object sender, RoutedEventArgs e)
        {
            personPopup.IsOpen = false;
        }

        private void personPopup_MouseLeave_1(object sender, System.Windows.Input.MouseEventArgs e)
        {
            personPopup.IsOpen = false;
        }

        private void personCenter_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            personPopup.IsOpen = true;
        }

        private void personCenter_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            //personPopup.IsOpen = false;
        }

        private void Image_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            
        }

        private void mini_btn_Click(object sender, RoutedEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }

        private void close_btn_Click(object sender, RoutedEventArgs e)
        {
            Application.Current.Shutdown();
        }

    }
}
